/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kenny.wiki.ejb.entity.facade;

import com.kenny.wiki.ejb.entity.User;
import com.kenny.wiki.ejb.entity.facade.remote.UserFacadeRemote;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Kenny Lin
 */
@Stateless
public class UserFacade extends AbstractFacade<User> implements UserFacadeRemote {
    @PersistenceContext(unitName = "Kenny-Wiki-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public UserFacade() {
        super(User.class);
    }
    
    public List<User> userLogin(String userName, String userPwd){
        String jpql = "select u from User u where u.userName='"+userName+"'and u.userPwd='"+userPwd+"'";
        return this.getEntityManager().createQuery(jpql).getResultList();
    }
}
